/*
 * ---------------------------------------------------------------------
 * Copyright (c) 2014, 2015 All Right Reserved
 * This software is developed for study and improve coding skill ...
 *
 * Project:  Excellent Coding< EC >
 *
 * ecSemaphore.h
 * This file for ecSemaphore define and encapsulation.
 *
 * Eamil:   epengao@126.com
 * Author:  Peter Gao
 * Version: Intial first version.
 * --------------------------------------------------------------------
 */

#ifndef EC_SEMAPHORE_H
#define EC_SEMAPHORE_H

#include "ecBaseType.h"

#ifdef _WIN32
#include <windows.h>
#else
#include <semaphore.h>
#endif

namespace ec {

class ecSemaphore
{
public:
    ecSemaphore(EC_U32 nInitSig=0, EC_U32 nMaxSig=EC_MAX_U16);
    ~ecSemaphore();

    void SemAddSIGNAL();
    void SemRemoveSIGNAL();

private:
#ifdef _WIN32
    HANDLE         m_hSemaphore;
#else
    sem_t          m_hSemaphore;
#endif
};

} /* namespace ec */
#endif /* EC_SEMAPHORE_H */